<!DOCTYPE html>
<html>
<head>
    <title>门店自营产品表</title>
		<#include "/header.html">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/plugins/treegrid/jquery.treegrid.css">
    <script src="${request.contextPath}/statics/libs/bootstrap-table.min.js"></script>
    <script src="${request.contextPath}/statics/plugins/treegrid/jquery.treegrid.min.js"></script>
    <script src="${request.contextPath}/statics/plugins/treegrid/jquery.treegrid.bootstrap3.js"></script>
    <script src="${request.contextPath}/statics/plugins/treegrid/jquery.treegrid.extension.js"></script>
    <script src="${request.contextPath}/statics/plugins/treegrid/tree.table.js"></script>
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <form class="form-inline" role="form">
                <a class="btn btn-default btn-sm" @click="reset"><i class="fa fa-refresh"></i></a>
                <div class="form-group">
                    <input type="text" class="form-control input-sm" v-model="q.productId" @keyup.enter="query" placeholder="门店商品productId">
                </div>&nbsp;&nbsp;&nbsp;
                <div class="form-group">
                    <input type="text" class="form-control input-sm" v-model="q.origProductId" @keyup.enter="query" placeholder="绑定紫云网sku">
                </div>&nbsp;&nbsp;&nbsp;
                <div class="form-group">
                    <input type="text" class="form-control input-sm" v-model="q.productName" @keyup.enter="query" placeholder="产品名称">
                </div>&nbsp;&nbsp;&nbsp;
                <a class="btn btn-default btn-sm"  @click="query"><i class="fa fa-search"></i>&nbsp;查询</a>
                <#if shiro.hasPermission("storeGoodsProduct:storegoodsproduct:save")>
                    <div class="form-group">
                        <a class="btn btn-primary btn-sm" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
                    </div>
                </#if>
                <#if shiro.hasPermission("storeGoodsProduct:storegoodsproduct:update")>
                    <div class="form-group">
                        <a class="btn btn-primary btn-sm" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
                    </div>
                </#if>
                <#if shiro.hasPermission("storeGoodsProduct:storegoodsproduct:delete")>
                    <div class="form-group">
                        <a class="btn btn-primary btn-sm" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
                    </div>
                </#if>
            </form>
        </div>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <div v-show="!showList" class="panel panel-default">
        <div class="panel-heading">{{title}}</div>
        <form class="form-horizontal" style="width: 100%;padding-top: 0px;">
            <el-table :data="storeGoodsProductList" width="90%" stripe  style="width: 100%">
                <el-table-column   label="产品名" width="180">
                    <template slot-scope="scope">
                        <el-input v-model="scope.row.productName" placeholder="请输入"></el-input>
                    </template>
                </el-table-column>
                <!--<el-table-column label="价格" width="180">-->
                    <!--<template slot-scope="scope">-->
                        <!--<el-input v-model="scope.row.price" v-bind:readonly="(scope.row.goodsFlag == 'spu')?true:false" type ="number" placeholder="请输入"></el-input>-->
                    <!--</template>-->
                <!--</el-table-column>-->
                <el-table-column label="重量" width="180">
                    <template slot-scope="scope">
                        <el-input v-model="scope.row.weight" v-bind:readonly="isBlank(scope.row.origProductId)?false:true" type ="number" placeholder="请输入"></el-input>
                    </template>
                </el-table-column>
                <el-table-column label="单位" width="180">
                    <template slot-scope="scope">
                        <el-input v-model="scope.row.unit" v-bind:readonly="isBlank(scope.row.origProductId)?false:true" placeholder="请输入"></el-input>
                    </template>
                </el-table-column>
                <el-table-column label="规格" width="360">
                    <template slot-scope="scope">
                        <el-input v-model="scope.row.craft" placeholder="请输入"></el-input>
                    </template>
                </el-table-column>
                <el-table-column prop="origProductId" label="绑定sku" width="80"></el-table-column>
                <el-table-column label="门店分类" width="180">
                    <template slot-scope="scope">
                        <el-input v-model="scope.row.storeCategoryId" readonly="readonly" @click.native="choiceStoreCategoryId(scope.$index)" placeholder="请双击选择门店分类"></el-input>
                    </template>
                </el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button
                                @click.native.prevent="delRow(scope.$index, storeGoodsProductList)"
                                type="text"
                                size="small">
                            移除
                        </el-button>
                        <el-button
                                @click.native.prevent="updateSku(scope.$index)"
                                type="text"
                                size="small">
                            修改绑定sku
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!--<input @click="addStoreGoodsProduct" value="添加产品" />-->
            <div class="form-group">
            <div class="col-sm-2 control-label"></div>
                <input v-if="title == '新增'" type="button" class="btn btn-primary  btn-sm" @click="addStoreGoodsProduct" value="新建商品"/>&nbsp;&nbsp;
                <input v-if="title == '新增'" type="button" class="btn btn-primary  btn-sm" @click="boundSku" value="绑定sku"/>&nbsp;&nbsp;
                <input  type="button" class="btn btn-primary  btn-sm" @click="saveOrUpdate" value="确定"/>&nbsp;&nbsp;
                <input type="button" class="btn btn-warning  btn-sm" @click="reload" value="返回"/>
            </div>
        </form>
    </div>
<!-- 绑定sku -->
    <!--<el-button type="text" @click="outerVisible = true">点击打开外层 Dialog</el-button>-->
<template>
    <el-dialog title="外层 Dialog" :visible.sync="outerVisible" height="100%">
        <!-- 商品三级分类选择 -->
        <el-dialog title="商品三级分类选择" :visible.sync="goodsCategoryDialogVisible" width="40%" append-to-body>
            <div class="el-form-item">
                <label class="el-form-item__label" style="width: 80px;">商品分类</label>
                <div class="el-form-item__content" style="margin-left: 80px;">
                    <el-cascader style="width: 90%" filterable
                                 v-model="categoryId"
                                 :options="categoryTree"
                                 @change="categoryChange">
                    </el-cascader>
                </div>
            </div>
            </span>
        </el-dialog>
        <template  height="100%">
            <div class="grid-btn">
                <form class="form-inline" role="form">
                    <!--<el-button type="info" plain @click="choiceCategory()">-->
                    <!--请选择三级分类-->
                    <!--</el-button>-->
                    <el-button type="primary" @click="goodsCategoryDialogVisible = true">请选择三级分类</el-button>
                    <div class="form-group">
                        <input type="text" class="form-control a input-sm" width="30px" v-model="spuQuery.goodsId" placeholder="商品Id">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control input-sm" v-model="spuQuery.name" placeholder="查询商品名">
                    </div>
                    <a class="btn btn-primary btn-sm" @click="loadSpuData"><i class="fa fa-search"></i>&nbsp;查询</a>
                    <div class="panel-heading">(*温馨提示:双击选择商品加载sku数据表格)</div>
                </form>
            </div>
            <template v-if="spuTableData != null">
                <el-table :data="spuTableData" height="250" width="90%" stripe @cell-dblclick="choiceSpu" style="width: 100%">
                    <el-table-column prop="goodsId" label="商品id" width="180"></el-table-column>
                    <el-table-column prop="name" label="商品名" ></el-table-column>
                </el-table>
            </template>
            <template v-else>
                <span class="panel-heading">数据待加载...</span>
            </template>
            <!--</template>-->
            <!--<template width="50%" style="border-left:1px solid #000">-->
            <template v-if="skuTableData != null">
                <div class="panel-heading">(*温馨提示:下列表格是选中商品的sku列表,双击即可添加至正在新建的活动商品中)<el-button @click="addAll" type="primary" plain>全部添加</el-button></div>
                <el-table :data="skuTableData"  height="250"  width="90%" stripe  style="width: 100%">
                    <el-table-column prop="productId" label="产品id" width="180"></el-table-column>
                    <el-table-column prop="totalPrice" label="产品价格" width="180"></el-table-column>
                    <el-table-column prop="optionNames" label="产品规格选项" width="180"></el-table-column>
                    <el-table-column label="操作">
                        <template slot-scope="scope">
                            <el-button size="mini" @click="choiceSku(scope.row)">
                                <span v-if="scope.row.addOrDel == false">添加</span>
                                <span v-else>删除</span>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
        </template>
        <div slot="footer" class="dialog-footer">
            <el-button @click="outerVisible = false">确 认</el-button>
        </div>
    </el-dialog>
</template>
<!-- 选择门店三级分类 -->
<div id="storeGoodsCategoryLayer" style="display: none;padding:10px;">
    <!--<el-dialog title="门店三级分类选择" :visible.sync="storeDialog" height="100%">-->
            <ul id="storeGoodsCategoryTree" class="ztree"></ul>
    <!--</el-dialog>-->
</div>
</div>

<script src="${request.contextPath}/statics/js/modules/store/storeGoodsProduct/storegoodsproduct.js?_${.now?long}"></script>
</body>
</html>